//
//  BSBluetoothSingleton.h
//  SuoSiApp
//
//  Created by zhang on 16/4/11.
//  Copyright © 2016年 Ym. All rights reserved.
//

#import <UIKit/UIKit.h>
#import <CoreBluetooth/CoreBluetooth.h>
#import "BSBluetoothViewController.h"

#import <Foundation/Foundation.h>

typedef void(^getBluSignal)();


@interface BSBluetoothSingleton : NSObject<CBCentralManagerDelegate,CBPeripheralDelegate>

/*
 1. 建立中心角色
 2. 扫描外设（discover）
 3. 连接外设(connect)
 4. 扫描外设中的服务和特征(discover)
  - 4.1 获取外设的services
  - 4.2 获取外设的Characteristics,获取Characteristics的值，获取Characteristics的Descriptor和Descriptor的值
 5. 与外设做数据交互(explore and interact)
 6. 订阅Characteristic的通知
 7. 断开连接(disconnect)
 */


@property (nonatomic, copy)getBluSignal getsignal;


//设置一个数组的属性 存储发现的设备
@property (nonatomic, strong) NSMutableArray *peripherals;

//设置一个中心管理者
@property (nonatomic, strong) CBCentralManager *manager;

// 创建一个tableView 来展示数据
//@property (nonatomic, strong) UITableView *tableview;
//搜到的外设
@property (nonatomic, strong) CBPeripheral *perpheral;
//外设的特征
@property (nonatomic, strong) CBCharacteristic *charactertic;
//信号强度
@property (nonatomic, assign) NSInteger RSSIValue;

//存储数据的路径
@property (nonatomic, strong) NSString *dataSourcePath;

@property (nonatomic, strong) NSMutableArray *dataArr;

@property (nonatomic, strong) NSFileHandle *fileHandle;





+ (BSBluetoothSingleton *)shareBlutooth;

//搜寻蓝牙
- (void)findBluetooth;
- (void)findBluetoothWithUUID:(NSString *)uuid;
//链接对应的蓝牙
- (void)connectPerpheralWithIndexpathrow:(NSInteger )row;
// 对应的控制器 用于展示搜到的蓝牙对象
@property (nonatomic, strong) BSBluetoothViewController *bsblueVC;

// 蓝牙转换的点 需要画图的
@property (nonatomic, strong) NSMutableArray *bluePointdrawArr, *bluePointdrawArr2, *bluePointdrawArr3;

//蓝牙的电压值
@property (nonatomic, assign) CGFloat batVolValue;
@property (nonatomic, assign) CGFloat  tempValue;

- (void)changeIsconect;


//定义个bool值 判断有没有成功链接蓝牙 用来判断佩戴模式 是跳向连接蓝牙 还是三通道界面
@property (nonatomic, assign) BOOL isConnected;

//文件 管理
@property (nonatomic, strong) NSFileManager *fileManager;
//所有data存放的路径
@property (nonatomic, strong) NSString *filePath;
- (void)writeDataTofile:(NSData *)data;
- (void)creatDataFile;
// 蓝牙一次性发送来的点
@property (nonatomic, strong) NSMutableArray *dataArrOnce1;
@property (nonatomic, strong) NSMutableArray *dataArrOnce2;

//分组处理蓝牙的数据 并保存在一个数组里
@property (nonatomic, strong) NSMutableArray *ECGDataArrWithArr;

//创建一个可变的data  包含我们拼接的data
@property (nonatomic, strong) NSMutableData *muData;

#pragma mark 设备信息使用提示
//设备信号弱提示音
@property (nonatomic, assign) BOOL isSignalWeak, isElectricLow, isDisconnected, isFall, isGPSON;
//根据时间获得文件名
@property (nonatomic, strong) NSString *fileNameWithDate;

//用 UUID 扫描找到的蓝牙
@property (nonatomic, strong) NSString *uuiduuid;
- (void)warningForSianalWeak;
- (void)warningForElectricLow;
- (void)warningForDisconnected;
- (void)warningForFall;

//接收蓝牙的data  用于实时上传
@property (nonatomic, strong) NSMutableData * NSMutableDataNOW;

//蓝牙的数据 是否已经初始化
@property (nonatomic, assign) BOOL isInit;
@property (nonatomic, assign) int heartRate;
#pragma mark 下面的属性 全是用 提示音的
@property (nonatomic, assign) NSInteger signalCount, ElectricLowCount, DisconnectedCount, FallCount, noteCount;

#pragma mark 准备三通道   这三个数据 用来接收以后三通道的数据
@property (nonatomic, strong) NSMutableArray *chanel1Arr;
@property (nonatomic, strong) NSMutableArray *chanel2Arr;
@property (nonatomic, strong) NSMutableArray *chanel3Arr;
@property (nonatomic, strong) NSMutableData *datatest;
//心率改来改去
@property (nonatomic, strong) NSMutableArray *HrateArr;

#pragma mark 三通道 数据帧的帧序号
@property (nonatomic, assign) int chanel1count, chanel2count, chanel3count;


@end
